# Programs, flags, etc.
ASM		= nasm
DASM		= ndisasm
AS		= as
CC		= gcc -march=i486
LD		= ld
AR		= ar
CPP		= gcc -E -nostdinc -I../../include
ASMFLAGS	= -f elf
ASFLAGS		= 
CFLAGS		= -Wall -O  -nostdinc -I../../include
LDFLAGS		= -r
ARFLAGS		= rcs

.c.o:
	$(CC) $(CFLAGS)	-c -o $*.o $<
.s.o:
	$(AS) -o $*.o $<
.S.o:
	$(ASM) $(ASMFLAGS) -o $*.o $<
.c.s:
	$(CC) $(CFLAGS) -S -o $*.s $<

# This Program
TARGET		= chr_drv.a 
OBJS		= console.o \
		  serial.o \
		  keyboard.o \
		  rs_io.o \
		  tty_io.o \
		  tty_ioctl.o

# All Phony Targets
.PHONY : all clean dep

# Default starting position
all : $(TARGET)

$(TARGET) : $(OBJS) 
	$(AR) $(ARFLAGS) $(TARGET) $(OBJS)
clean:
	rm -f core $(TARGET)
cleanall :
	rm -f core *.o *.a tmp_make
#	for i in *.c; do rm -f 'basename $$i .c'.s;done
dep:
	sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
	(for i in *.c;do $(CPP) -M $$i;done) >> tmp_make
	cp tmp_make Makefile
	rm tmp_make

### Dependencies:
console.o: console.c ../../include/const.h ../../include/linux/sched.h \
  ../../include/linux/fs.h ../../include/sys/types.h \
  ../../include/linux/head.h ../../include/linux/mm.h \
  ../../include/signal.h ../../include/linux/tty.h \
  ../../include/termios.h ../../include/asm/io.h \
  ../../include/asm/system.h
serial.o: serial.c ../../include/linux/tty.h ../../include/termios.h \
  ../../include/linux/sched.h ../../include/linux/fs.h \
  ../../include/sys/types.h ../../include/linux/head.h \
  ../../include/linux/mm.h ../../include/signal.h \
  ../../include/asm/system.h ../../include/asm/io.h
tty_io.o: tty_io.c ../../include/ctype.h ../../include/errno.h \
  ../../include/signal.h ../../include/sys/types.h \
  ../../include/linux/sched.h ../../include/linux/fs.h \
  ../../include/linux/head.h ../../include/linux/mm.h \
  ../../include/linux/tty.h ../../include/termios.h \
  ../../include/asm/segment.h ../../include/asm/system.h
tty_ioctl.o: tty_ioctl.c ../../include/errno.h ../../include/termios.h \
  ../../include/linux/sched.h ../../include/linux/fs.h \
  ../../include/sys/types.h ../../include/linux/head.h \
  ../../include/linux/mm.h ../../include/signal.h \
  ../../include/linux/kernel.h ../../include/stdarg.h \
  ../../include/linux/tty.h ../../include/asm/io.h \
  ../../include/asm/segment.h ../../include/asm/system.h
